function encryptAbogus(userAgent, query, body = '') {
    function lmStrEncode(lmArr, table) {
        let dataStr = '';
        let groupNum = lmArr.length / 3;
        for (let i = 0; i < groupNum; i++) {
            lmCha1 = lmArr[3 * i]
            lmCha2 = lmArr[3 * i + 1]
            lmCha3 = lmArr[3 * i + 2]

            bigNum = (lmCha1 & 255) << 16 | ((lmCha2 & 255) << 8) | (lmCha3 & 255)

            chr1 = table.charAt((bigNum & 16515072) >> 18);
            chr2 = table.charAt((bigNum & 258048) >> 12);
            chr3 = table.charAt((bigNum & 4032) >> 6);
            chr4 = table.charAt(bigNum & 63);

            dataStr += `${chr1}${chr2}${chr3}${chr4}`

        }
        // 填充逻辑
        const remainder = lmArr.length % 3;
        if (remainder === 1) {
            dataStr = dataStr.substring(0, dataStr.length - 2);
            dataStr += '==';
        } else if (remainder === 2) {
            dataStr = dataStr.substring(0, dataStr.length - 1);
            dataStr += '=';
        }


        // 填充逻辑 3字符 -> 4编码
        return dataStr
    }

    function parse(lmStr, dataStr) {
        // 计算生成乱码
        let retStr = ''
        let arr256 = [...Array(256).keys()].map(i => 255 - i);


        // 计算偏移 位置交换 边计算边移动
        for (var s = 0, swapIdx = 0; s < arr256.length; s++) {
            swapIdx = ((swapIdx * arr256[s] + swapIdx) + lmStr.charCodeAt(s % lmStr.length)) % 256;
            // console.log(s, swapIdx)
            // 当前遍历元素 <-> 计算索引元素 交换
            let tmp = arr256[s];
            arr256[s] = arr256[swapIdx];
            arr256[swapIdx] = tmp;
        }

        for (let i = 0, bak = 0; i < dataStr.length; i++) {
            let idx = (i + 1) % 256;
            let idx2 = (bak + arr256[idx]) % 256;
            let idx3 = (arr256[idx2] + arr256[idx]) % 256;

            bak = idx2 // 暂存值 - 前后运算相关

            // 位置交换
            let tmp2 = arr256[idx];
            arr256[idx] = arr256[idx2];
            arr256[idx2] = tmp2;

            let num = dataStr.charCodeAt(i) ^ arr256[idx3];
            retStr += String.fromCharCode(num);


        }

        return retStr
    }

    function getaBogusLmArr4() {
        // aBogus 拼接乱码4位数组 aBogus乱码前缀 - 两个随机数相关
        let randomVal1 = (Math.random() * 65535) & 255;
        let randomVal2 = Math.random() * 40;
        return [
            (randomVal1 & 170) | 1,
            (randomVal1 & 85) | 2,
            ((randomVal2 >> 0) & 170) | 80,
            ((randomVal2 >> 0) & 85) | 2
        ]
    }

    function getTmArr(tm) {
        // 时间戳 构造数组 tm和arr50 - 索引 4 5 6 7 8 9
        tmNum = (tm + 3) & 255;
        tmStr = `${tmNum},`
        let tmArr = [];
        for (let i = 0; i < tmStr.length; i++) {
            tmArr.push(tmStr.charCodeAt(i));
        }
        return tmArr;
    }

    function getFpArr() {
        // 浏览器指纹收集 环境检测 宽度-高度 芯片类型...
        let fpArr = [];
        let fpStr = '1440|150|1440|823|1920|1055|1920|1080|MacIntel'
        for (let i = 0; i < fpStr.length; i++) {
            fpArr.push(fpStr.charCodeAt(i));
        }
        return fpArr;
    }

    function sumEncrypt(data) {
        function be(t, e, r, n) {
            return 0 <= t && t < 16 ? (e ^ r ^ n) >>> 0 : 16 <= t && t < 64 ? (e & r | ~e & n) >>> 0 : (console.error("invalid j for bool function GG"),
                0)
        }

        function me(t, e, r, n) {
            return 0 <= t && t < 16 ? (e ^ r ^ n) >>> 0 : 16 <= t && t < 64 ? (e & r | e & n | r & n) >>> 0 : (console.error("invalid j for bool function FF"),
                0)
        }

        function de(t) {
            return 0 <= t && t < 16 ? 2043430169 : 16 <= t && t < 64 ? 2055708042 : void console.error("invalid j for constant Tj")
        }

        function ye(t, e) {
            return (t << (e %= 32) | t >>> 32 - e) >>> 0
        }

        function t() {
            if (function (t, e) {
                if (!(t instanceof e))
                    throw new TypeError("Cannot call a class as a function")
            }(this, t),
                !(this instanceof t))
                return new t;
            this.reg = new Array(8),
                this.chunk = [],
                this.size = 0,
                this.reset()
        }

        function reset() { // sm3
            this.reg[0] = 1937774191,
                this.reg[1] = 1226093241,
                this.reg[2] = 388252375,
                this.reg[3] = 3666478592,
                this.reg[4] = 2842636476,
                this.reg[5] = 372324522,
                this.reg[6] = 3817729613,
                this.reg[7] = 2969243214,
                this.chunk = [],
                this.size = 0
        }

        function write(t) {
            var e = "string" == typeof t ? function (t) {
                var e = encodeURIComponent(t).replace(/%([0-9A-F]{2})/g, (function (t, e) {
                        return String.fromCharCode("0x" + e)
                    }
                ))
                    , r = new Array(e.length);
                return Array.prototype.forEach.call(e, (function (t, e) {
                        r[e] = t.charCodeAt(0)
                    }
                )),
                    r
            }(t) : t;
            this.size += e.length;
            var r = 64 - this.chunk.length;
            if (e.length < r)
                this.chunk = this.chunk.concat(e);
            else
                for (this.chunk = this.chunk.concat(e.slice(0, r)); this.chunk.length >= 64;)
                    this._compress(this.chunk),
                        r < e.length ? this.chunk = e.slice(r, Math.min(r + 64, e.length)) : this.chunk = [],
                        r += 64
        }

        function _compress(t) {
            if (t < 64)
                console.error("compress error: not enough data");
            else {
                for (var e = function (t) {
                    for (var e = new Array(132), r = 0; r < 16; r++)
                        e[r] = t[4 * r] << 24,
                            e[r] |= t[4 * r + 1] << 16,
                            e[r] |= t[4 * r + 2] << 8,
                            e[r] |= t[4 * r + 3],
                            e[r] >>>= 0;
                    for (var n = 16; n < 68; n++) {
                        var o = e[n - 16] ^ e[n - 9] ^ ye(e[n - 3], 15);
                        o = o ^ ye(o, 15) ^ ye(o, 23),
                            e[n] = (o ^ ye(e[n - 13], 7) ^ e[n - 6]) >>> 0
                    }
                    for (n = 0; n < 64; n++)
                        e[n + 68] = (e[n] ^ e[n + 4]) >>> 0;
                    return e
                }(t), r = this.reg.slice(0), n = 0; n < 64; n++) {
                    var o = ye(r[0], 12) + r[4] + ye(de(n), n)
                        , i = ((o = ye(o = (4294967295 & o) >>> 0, 7)) ^ ye(r[0], 12)) >>> 0
                        , u = me(n, r[0], r[1], r[2]);
                    u = (4294967295 & (u = u + r[3] + i + e[n + 68])) >>> 0;
                    var c = be(n, r[4], r[5], r[6]);
                    c = (4294967295 & (c = c + r[7] + o + e[n])) >>> 0,
                        r[3] = r[2],
                        r[2] = ye(r[1], 9),
                        r[1] = r[0],
                        r[0] = u,
                        r[7] = r[6],
                        r[6] = ye(r[5], 19),
                        r[5] = r[4],
                        r[4] = (c ^ ye(c, 9) ^ ye(c, 17)) >>> 0
                }
                for (var a = 0; a < 8; a++)
                    this.reg[a] = (this.reg[a] ^ r[a]) >>> 0
            }
        }

        function _fill() {
            var t = 8 * this.size
                , e = this.chunk.push(128) % 64;
            for (64 - e < 8 && (e -= 64); e < 56; e++)
                this.chunk.push(0);
            for (var r = 0; r < 4; r++) {
                var n = Math.floor(t / 4294967296);
                this.chunk.push(n >>> 8 * (3 - r) & 255)
            }
            for (r = 0; r < 4; r++)
                this.chunk.push(t >>> 8 * (3 - r) & 255)
        }

        function sum(t, e) {
            t && (this.reset(),
                this.write(t)),
                this._fill();
            for (var r = 0; r < this.chunk.length; r += 64)
                this._compress(this.chunk.slice(r, r + 64));
            var n, o, i, u = null;
            if ("hex" == e) {
                u = "";
                for (r = 0; r < 8; r++)
                    u += (n = this.reg[r].toString(16),
                        o = 8,
                        i = "0",
                        n.length >= o ? n : i.repeat(o - n.length) + n)
            } else
                for (u = new Array(32),
                         r = 0; r < 8; r++) {
                    var c = this.reg[r];
                    u[4 * r + 3] = (255 & c) >>> 0,
                        c >>>= 8,
                        u[4 * r + 2] = (255 & c) >>> 0,
                        c >>>= 8,
                        u[4 * r + 1] = (255 & c) >>> 0,
                        c >>>= 8,
                        u[4 * r] = (255 & c) >>> 0
                }
            return this.reset(),
                u


        }

        t.prototype.reset = reset;
        t.prototype.write = write;
        t.prototype._compress = _compress;
        t.prototype._fill = _fill;
        t.prototype.sum = sum;
        obj = new t();
        return obj.sum(data);
    }

    function getXorRandomArr8() { //[3, 85, 34, 1,    43, 4, 162, 85
        // 异或计算58数组前8位随机生成 参与前8位异或运算
        randomVal1 = Math.random() * 65535
        tmpVal1 = (randomVal1 & 255) & 255
        tmpVal2 = (randomVal1 >> 8) & 255
        num1 = (tmpVal1 & 170) | 1
        num2 = (tmpVal1 & 85) | 0
        num3 = (tmpVal2 & 170) | 0
        num4 = (tmpVal2 & 85) | 0

        // 随机算法不一致
        randomVal = Math.random() * 255;
        randomVal2 = Math.random() * 240;
        isEven = (randomVal2 >> 0) + 110;
        isEven = isEven % 2 === 0 ? isEven : ++isEven;

        num5 = (isEven & 170) | 1;
        num6 = (isEven & 85) | 0;
        num7 = (((((((randomVal >> 0) & 77) | 2) | 16) | 32) | 128) & 170) | 16
        num8 = (((((((randomVal >> 0)) & 77) | 16) | 32) | 128) & 85) | 2;
        return [num1, num2, num3, num4, num5, num6, num7, num8];
    }

    function getNewArr50(arr50) {
        // 排序arr50 提取和真实后续传参不一致
        orderedArr50 = new Array(50)
        orderedArr50[0] = arr50[9]
        orderedArr50[1] = arr50[18]
        orderedArr50[2] = arr50[28]
        orderedArr50[3] = arr50[32]
        orderedArr50[4] = arr50[11]
        orderedArr50[5] = arr50[4]
        orderedArr50[6] = arr50[11]
        orderedArr50[7] = arr50[11]
        orderedArr50[8] = arr50[9]
        orderedArr50[9] = arr50[23]
        orderedArr50[10] = arr50[12]
        orderedArr50[11] = arr50[37]
        orderedArr50[12] = arr50[24]
        orderedArr50[13] = arr50[39]
        orderedArr50[14] = arr50[3]
        orderedArr50[15] = arr50[22]
        orderedArr50[16] = arr50[35]
        orderedArr50[17] = arr50[11]
        orderedArr50[18] = arr50[5]
        orderedArr50[19] = arr50[42]
        orderedArr50[20] = arr50[1]
        orderedArr50[21] = arr50[27]
        orderedArr50[22] = arr50[33]
        orderedArr50[23] = arr50[11]
        orderedArr50[24] = arr50[30]
        orderedArr50[25] = arr50[14]
        orderedArr50[26] = arr50[6]
        orderedArr50[27] = arr50[7]
        orderedArr50[28] = arr50[2]
        orderedArr50[29] = arr50[43]
        orderedArr50[30] = arr50[15]
        orderedArr50[31] = arr50[11]
        orderedArr50[32] = arr50[29]
        orderedArr50[33] = arr50[25]
        orderedArr50[34] = arr50[16]
        orderedArr50[35] = arr50[11]
        orderedArr50[36] = arr50[8]
        orderedArr50[37] = arr50[38]
        orderedArr50[38] = arr50[26]
        orderedArr50[39] = arr50[17]
        orderedArr50[40] = arr50[9]
        orderedArr50[41] = arr50[11]
        orderedArr50[42] = arr50[11]
        orderedArr50[43] = arr50[0]
        orderedArr50[44] = arr50[31]
        orderedArr50[45] = arr50[7]
        orderedArr50[46] = arr50[46]
        orderedArr50[47] = arr50[47]
        orderedArr50[48] = arr50[48]
        orderedArr50[49] = arr50[49]
        return orderedArr50
    }

    function getXorArray(arr) {
        let xorResult = 0;
        for (let i = 0; i < arr.length; i++) {
            xorResult ^= arr[i]; // 使用 ^= 运算符进行异或
        }
        return [xorResult];
    }

    function strToIntArr(dataStr) {
        // 字符串转位字节数组
        return Array.from(dataStr).map((char, index) => {
            return char.charCodeAt(0);
        });
    }

    // web端验签 -> a_bogus V 1.0.1.18 from bdms.js
    const tableObj = {
        "s0": "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", // 标准
        "s1": "Dkdpgh4ZKsQB80/Mfvw36XI1R25+WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=",
        "s2": "Dkdpgh4ZKsQB80/Mfvw36XI1R25-WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=", // xb
        "s3": "ckdp1h4ZKsUB80/Mfvw36XIgR25+WQAlEi7NLboqYTOPuzmFjJnryx9HVGDaStCe", // ua
        "s4": "Dkdpgh2ZmsQB80/MfvV36XI1R45-WUAlEixNLwoqYTOPuzKFjJnry79HbGcaStCe" // ab
    }

    const salt = 'dhzx'

    const tm2 = new Date().getTime() - 1
    const tm1Before = new Date().getTime()
    const fpArr = getFpArr();
    const queryArr32 = sumEncrypt(sumEncrypt(`${query}${salt}`))
    const dataArr32 = sumEncrypt(sumEncrypt(`${body}${salt}`))
    const userAgentLmStr = parse(String.fromCharCode(...[0.00390625, 1, 14]), userAgent)
    const userAgentArr32 = sumEncrypt(lmStrEncode(strToIntArr(userAgentLmStr), tableObj.s3))


    const tm1 = new Date().getTime()
    let arr50 = [
        // arr50相关 - 时间戳 query data ua 鼠标轨迹
        41, //   ^ 右=> 41
        8,
        6,
        ((tm1 - tm1Before) + 3) & 255,
        (tm1 >> 0) & 255,
        (tm1 >> 8) & 255,
        (tm1 >> 16) & 255,
        (tm1 >> 24) & 255,
        ((((tm1 / 256) / 256) / 256) / 256) & 255,
        (((((tm1 / 256) / 256) / 256) / 256) / 256) & 255,

        (1 % 256) & 255,
        (1 / 256) & 255,

        129,
        (129 >> 8) & 255,

        // 鼠标轨迹相关
        0, 0, 1, 0,

        (14 >> 0) & 255,
        (14 >> 8) & 255,
        (14 >> 16) & 255,
        (14 >> 24) & 255,

        // 索引23
        queryArr32[9],
        queryArr32[18],
        queryArr32[3],
        dataArr32[10],
        dataArr32[19],
        dataArr32[4],
        userAgentArr32[11],
        userAgentArr32[21],
        userAgentArr32[5],
        // 索引31

        (tm2 >> 0) & 255,
        (tm2 >> 8) & 255,
        (tm2 >> 16) & 255,
        (tm2 >> 24) & 255,
        ((((tm2 / 256) / 256) / 256) / 256) & 255,
        (((((tm2 / 256) / 256) / 256) / 256) / 256) & 255,

        3,
        // 常量值运算
        (33666 >> 0) & 255,
        (33666 >> 8) & 255,
        (33666 >> 16) & 255,
        (33666 >> 24) & 255,

        (1522 >> 0) & 255,
        (1522 >> 8) & 255,
        (1522 >> 16) & 255,
        (1522 >> 24) & 255,

        46, 0, 4, 0
    ]
    const newArr50 = getNewArr50(arr50) // 暂时一致
    const xorRandomArr8 = getXorRandomArr8()
    const arr58 = [...xorRandomArr8, ...arr50]
    const xorArray = getXorArray(arr58)
    const arr4Merge = [...newArr50, ...fpArr, ...getTmArr(tm1), ...xorArray]
    let aBogusLmStr = String.fromCharCode(...getaBogusLmArr4()) // ok
    let mergeArr = []; // ok
    for (let i = 0; i < arr4Merge.length / 3; i++) {
        // 遍历数组 每次取3位 然后计算
        let val1 = arr4Merge[3 * i]
        let val2 = arr4Merge[3 * i + 1]
        let val3 = arr4Merge[3 * i + 2]
        const randomVal = (Math.random() * 1000) &  255;
        mergeArr.push(
            (randomVal & 145) | (val1 & 110),
            (randomVal & 66) | (val2 & 189),
            (randomVal & 44) | (val3 & 211),
            ((val1 & 145) | (val2 & 66)) | (val3 & 44)
        )
    }
    let bigArr = xorRandomArr8.concat(
        mergeArr,
        xorArray
    )
    aBogusLmStr += parse(String.fromCharCode(...[211]), String.fromCharCode(...bigArr))
    return lmStrEncode(strToIntArr(aBogusLmStr), tableObj.s4);
}

// userAagent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
// query = "is_h5=1&is_native_h5=1&origin_type=detail_share_v2&verifyFp=verify_m3rf7nx0_47JMbxPB_HCBA_488s_9IXG_H2ECkvZokATm&msToken=y8S1jaECE5zraMhIGxfuSVmWS9eu3bJNmx9VK5kCmVUv7SJfIWtl1ic9cI1m_GDQE9zYBNLr7w060BlrEPC31AuIh0b6fKLE-8KCmh3Abfjup92f7IuI4er-dz3rFL21WC3XZWrGHHx01k2dDM5AjEJq3OewZaEIfJAxCzEpIp42WJ9vlViFEQ%3D%3D"
// body = "ui_params=%7B%22from_live%22%3Afalse%2C%22from_video%22%3Anull%2C%22three_d_log_data%22%3Anull%2C%22follow_status%22%3Anull%2C%22which_account%22%3Anull%2C%22ad_log_extra%22%3Anull%2C%22from_group_id%22%3Anull%2C%22bolt_param%22%3Anull%2C%22transition_tracker_data%22%3Anull%2C%22selected_ids%22%3Anull%2C%22window_reposition%22%3Anull%2C%22is_short_screen%22%3Anull%2C%22full_mode%22%3Atrue%7D&use_new_price=1&is_h5=1&bff_type=2&is_in_app=0&origin_type=detail_share_v2&promotion_ids=3709033952699351389&meta_param=&source_page=&request_additions=&isFromVideo=false&enable_timing=true&gtp_generated_product_desc=eyJ2ZXJzaW9uIjoiVjItREtNUyIsInRva2VuX2JvZHkiOiJNSUlCTVFRUUxuV1o4bDdFS1ZLVkpXcVQ3NERtZlFTQ0FSbkg0ZXU5TmN2bTludWtoeGNpQXIwb0RhU1hQc0psaUNIcXp3LWtFOG14cmcyNmZIZ1N6SU9TMEEtUmlsTlBhNnFSTWlRYWVYbF8teWRCaDR5VTYtTWRWZ0tsNjFjeUc5eHptcElqTzU0aUFIWGNZX1RJSmpRNVZXTjh0OUpUcy0tM21vOHlYU05xUW1KYmtGR2tBUlExMXU4aWdYM0o5cEhSbGhWak9uZ0tqUDEwamhod0VXdWxVSXFhODVUcmVVLTdNcmFxczBRdEIyQUlIRWlSMXU2RHVsTVd6OUlUeEw4bTFrUjNyOXRacmN1clctS1RUOXU0TUNFMk1lYmNLVTQ4LW4yTjVzclVvYTREdU1kOFRxQW5xdTlyYlNCR2pFMmNJMVFqVWt1bU84cEtqLWpzeGRZYTExdk52UXFSdG5BRnhncEdGYXN6TU5XY2g1aFlEVjQzbDJoc3lTajNqMHpuWTcxZl9KMWU5V19oa3U2NHh1US00UVFBIn0&is_new_h5_bff=1"
// console.log(encryptAbogus(userAagent, query, body))


